package com.atguigu.springCloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @author zgw
 * @date 2020/4/8 20:25
 */
@Component
@EnableBinding(Sink.class)//sink表示这是消息消费者
public class ReceiveMessageListenerControlle {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)//消息监听器
    public void input(Message<String> message) {
        System.out.println("端口号为"+serverPort+"的消费者，接收到的消息为："+message.getPayload());
    }
}
